package com.neuedu.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class Sqlutil {
    static {
    	try {
			Class.forName(Para.DRIVER);
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
    }
    
    public static Connection getConn() throws Exception {
    	return DriverManager.getConnection(Para.URL,Para.USERNAME,Para.PASSWORD);
    }
    
    public static void close(Object ...objects) {
    	if(objects!=null&objects.length>0) {
    		try {
    			for(Object obj:objects) {
    				if(obj instanceof Connection) {
    					((Connection)obj).close();
    				}
    				if(obj instanceof Statement) {
    					((Statement)obj).close();
    				}
    				if(obj instanceof ResultSet) {
    					((ResultSet)obj).close();
    				}
    				
    			}
    		}catch(Exception e) {
    			e.printStackTrace();
    		}
    	}
    }
    
    public static void main(String[] args) throws Exception {
		System.out.println(getConn());
	}
}
